package top.leetcode;

/**
 * @Desc
 * @Author houruiyang
 * @Date 2022/12/28
 **/
public class _070 {
    public int climbStairs(int n) {
        int p = 0;
        int q = 0;
        int r = 1;

        for (int i = 1; i <= n ; i++) {
            p =q;
            q = r;
            r = p +1;
        }

        return r;
    }


    public int dp(int n) {
        int[] dp = new int[n + 1];
        dp[0] = 1;
        dp[1] = 1;

        for (int i = 2; i <=n; i++) {
            dp[i] = dp[i -1] + dp[i -2];
        }

        return dp[n];
    }
}
